// 封装登录、购物车接口
import request from "../utils/request"
// 封装登录接口
export function loginApi(userName, password) {
    const formData = new FormData();
    formData.append("username", userName)
    formData.append("rememberMe", "true")
    formData.append("password", password)
    return request.post("/api/api/login", formData)
}

//获取当前登录用户的信息
export function getUserInfo() {
    return request.get(`/api/api/login-user/info`)
}


//修改头像
export function uploadphotos(avatarfile) {
    const formData = new FormData();
    formData.append("avatarfile", avatarfile)
    // formData.append("fileUseForEnum", fileUseForEnum)
    return request.post('/api/api/system/user/profile/update/avatar/nos',formData)
}

//修改信息
export function modifynformation(userName,phonenumber) {
    const formData = new FormData();
    formData.append("userName", userName)
    formData.append("phonenumber", phonenumber)
    return request.post('/api/api/system/user/profile/update',formData)
}


// 封装修改密码接口
export function changePass(loginName, password,phonenumber,code) {
    const formData = new FormData();
    formData.append("loginName", loginName)

    formData.append("password", password)
    formData.append("phonenumber", phonenumber)
    formData.append("code", code)
    return request.post("/api/api/password/forget", formData)
}



// /pcUser/logout  退出登录
export function logOut() {
    return request.get('/api/api/logout')
}



//获取验证码
export function registerCode(mobile) {
    return request.get(`/api/api/short-message/vcode/${mobile}`)
}


//注册
export function register(loginName,code,phonenumber,password,userName) {
    const formData = new FormData();
    formData.append("loginName", loginName)
    formData.append("code", code)
    formData.append("phonenumber", phonenumber)
    formData.append("password", password)
    formData.append("userName", userName)
    return request.post('/api/api/registry', formData)

}

//收藏列表
export function collection() {
    return request.get(`/api/api/cms/article/collect/list`)
}